package com.concurrent.chapter7.concurrent01;

import java.util.concurrent.Callable;

public class MyCallableB2 implements Callable<String> {

	@Override
	public String call() throws Exception {
		System.out.println("MyCallableB2.call() begin " + System.currentTimeMillis());
		for (int i = 0; i < 500; i++) {
			if (!Thread.interrupted()) {
				Math.random();
				Math.random();
				Math.random();
				System.out.println("MyCallableB2.call() " + i);
			} else {
				System.out.println("MyCallableB2.call() 抛出异常中断了");
				throw new InterruptedException();
			}
		}
		System.out.println("MyCallableB2.call() end " + System.currentTimeMillis());
		return "MyCallableB2_return";
	}
}
